#include <stdio.h>
#include <stdlib.h>

#define MAXNUM 100

typedef int DataType;
typedef enum bool Bool;
enum bool {
        false, true
};

/* struct LinearList {
        DataType element[MAXNUM]; // 静态存储
        int len;
}; */

struct LinearList {
        int Maxnum;
        DataType *element; // 动态存储
        int len;
};
typedef struct LinearList *List;

List CreateNewList(int m)
{
        // 动态分配一个struct LinearList给list.
        List list = (List)malloc(sizeof(struct LinearList));
        // 为list中的成员变量element动态分配一块长度为m存储空间.
        list->element = (DataType *)calloc(m, sizeof(DataType));
        list->len = m;
        list->Maxnum = 100;
        return list;
}

Bool IsEmptyList(List list)
{
        return list->len == 0;
}

int LinearSearch(List list, DataType x)
{
        if (IsEmptyList(list))
                return false;
        for (int p = 0; p < list->len; p++)
                if (list->element[p] == x)
                        return p;
        return -1;
}

Bool InsertPre(List list, int p, DataType x)
{
        if (list->len >= list->Maxnum)
                return false;
        if (p < 0 || p > list->len - 1)
                return false;
        for (int i = list->len-1; i >= p; i--)
                list->element[i+1] = list->element[i];
        list->element[p] = x;
        list->len++;
        return true;
}

Bool InsertPost(List list, int p, DataType x)
{
        if (list->len >= list->Maxnum)
                return false;
        if (p < 0 || p > list->len)
                return false;
        for (int j = list->len-1; j >= p + 1; j--)
                list->element[j+1] = list->element[j];
        list->element[p+1] = x;
        list->len++;
        return true;
}

Bool DeleteItem(List list, int p)
{
        if (IsEmptyList(list))
                return false;
        if (p < 0 || p > list->len)
                return false;
        if (list->len == 1) {
                list->len--;
                return true;
        }
        for (int k = p + 1; k <= list->len - 1; k++)
                list->element[k-1] = list->element[k];
        list->len--;
        return true;
}

Bool DeleteFirstItem(List list, DataType x)
{
        int p = LinearSearch(list, x);
        if (-1 == p) {
                return false;
        } else {
                if (DeleteItem(list, p))
                        return true;
        }
}

void print_all(List list)
{
        for (int i = 0; i < list->len; i++) {
                printf("%d ", list->element[i]);
        }
        printf("\n");
}

void fuzhi(List list)
{
        for (int i = 0; i < list->len; i++) {
                list->element[i] = i;
        }
}

int main()
{
        int m, x, p;
        scanf("%d%d%d", &m, &x, &p);
        List list = CreateNewList(m);
        // printf("%d\n", list->len);
        print_all(list);
        fuzhi(list);
        print_all(list);

        if (IsEmptyList(list))
                printf("list is a empty list.\n");

        if (-1 != LinearSearch(list, x)) {
                printf("Got it!\n");
        } else {
                printf("Not found it!\n");
        }

        if (InsertPre(list, p, x)) {
                print_all(list);
        }

        if (InsertPost(list, 2, x)) {
                print_all(list);
        }

        if (DeleteItem(list, 1)) {
                print_all(list);
        }

        if (DeleteFirstItem(list, x)) {
                print_all(list);
        }

        return 0;
}
